package edu.polsl.bio.str.common.entity;

import edu.polsl.bio.str.common.constant.NodeState;

import javax.persistence.*;
import java.util.Date;

/**
 * //todo class description
 * <p/>
 * Created on: Jun 13, 2011 6:34:12 PM <br/>
 * <a href="http://www.polsl.pl">www.polsl.pl</a>
 *
 * @author lukasz.olczak@polsl.pl
 */
@Entity
@Table(name = "nodes")
public class Node extends BaseEntity {

  private String nodeIp;

  private Integer tokens;

  private Date lastHeartbeat;

  private NodeState nodeState;

  private Integer noCpu;

  @Column(name = "no_cpu", nullable = false)
  public Integer getNoCpu() {
    return noCpu;
  }

  public void setNoCpu(Integer noCpu) {
    this.noCpu = noCpu;
  }

  @Enumerated(EnumType.STRING)
  @Column(name = "state", nullable = false)
  public NodeState getNodeState() {
    return nodeState;
  }

  public void setNodeState(NodeState nodeState) {
    this.nodeState = nodeState;
  }

  @Column(name = "node_ip", nullable = false)
  public String getNodeIp() {
    return nodeIp;
  }

  public void setNodeIp(String nodeIp) {
    this.nodeIp = nodeIp;
  }

  public Integer getTokens() {
    return tokens;
  }

  public void setTokens(Integer tokens) {
    this.tokens = tokens;
  }

  @Column(name = "last_heartbeat", nullable = false)
  public Date getLastHeartbeat() {
    return lastHeartbeat;
  }

  public void setLastHeartbeat(Date lastHeartbeat) {
    this.lastHeartbeat = lastHeartbeat;
  }

  @Override
  public String toString() {
    return "Node{" +
           "lastHeartbeat=" + lastHeartbeat +
           ", nodeIp='" + nodeIp + '\'' +
           ", tokens=" + tokens +
           ", nodeState=" + nodeState +
           ", noCpu=" + noCpu +
           "} " + super.toString();
  }
}
